<!DOCTYPE html>
<html>
<head hexo-theme='https://github.com/volantis-x/hexo-theme-volantis/tree/4.0.0-rc.4'>
  <meta charset="utf-8">
  <!-- SEO相关 -->
  
    
  
  <!-- 渲染优化 -->
  <meta name="renderer" content="webkit">
  <meta name="force-rendering" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <meta name="HandheldFriendly" content="True" >
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta http-equiv='x-dns-prefetch-control' content='on' />

  <!-- 页面元数据 -->
  
  <title>生产实习 - CC康纳百川</title>
  
    <meta name="keywords" content="学习,生产实习">
  

  

  <!-- feed -->
  

  <!-- import meta -->
  

  <!-- link -->
  <link rel='dns-prefetch' href='https://cdn.jsdelivr.net'>
  
    
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.14/css/all.min.css">

  
  

  

  

  

  

  <!-- import link -->
  

  
  
    
<link rel="stylesheet" href="/volantis/css/style.css">

  
  
  
  <!-- 脚本懒加载函数 -->
  <script>
  function loadScript(src, cb) {
    var HEAD = document.getElementsByTagName('head')[0] || document.documentElement;
    var script = document.createElement('script');
    script.setAttribute('type','text/javascript');
    if (cb) script.onload = cb;
    script.setAttribute('src', src);
    HEAD.appendChild(script);
  }
  //https://github.com/filamentgroup/loadCSS
  !function(c){"use strict";var e=function(e,t,n,r){var o,i=c.document,a=i.createElement("link");if(t)o=t;else{var d=(i.body||i.getElementsByTagName("head")[0]).childNodes;o=d[d.length-1]}var f=i.styleSheets;if(r)for(var l in r)r.hasOwnProperty(l)&&a.setAttribute(l,r[l]);a.rel="stylesheet",a.href=e,a.media="only x",function e(t){if(i.body)return t();setTimeout(function(){e(t)})}(function(){o.parentNode.insertBefore(a,t?o:o.nextSibling)});var s=function(e){for(var t=a.href,n=f.length;n--;)if(f[n].href===t)return e();setTimeout(function(){s(e)})};function u(){a.addEventListener&&a.removeEventListener("load",u),a.media=n||"all"}return a.addEventListener&&a.addEventListener("load",u),(a.onloadcssdefined=s)(u),a};"undefined"!=typeof exports?exports.loadCSS=e:c.loadCSS=e}("undefined"!=typeof global?global:this);
  </script>
  <script id="loadcss"></script>
</head>

<body>
  <header class="l_header auto shadow blur " style='opacity: 0' >
  <div class='container'>
  <div class='wrapper'>
    <div class='nav-sub'>
      <p class="title"></p>
      <ul class='switcher nav-list-h m-phone' id="pjax-header-nav-list">
        <li><a class="s-comment fas fa-comments fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
          <li><a class="s-toc fas fa-list fa-fw" target="_self" href='javascript:void(0)'></a></li>
        
      </ul>
    </div>
		<div class="nav-main">
      
        
        <a class="title flat-box" target="_self" href='/volantis/'>
          
            <img no-lazy class='logo' src='https://cdn.jsdelivr.net/gh/ccknbc-backup/cdn/logo/logo.png'/>
          
          
          
        </a>
      

			<div class='menu navigation'>
				<ul class='nav-list-h m-pc'>
          
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/
                  
                  
                  
                    id="volantis"
                  >
                  <i class='fas fa-rss fa-fw'></i>博客
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/categories/
                  
                  
                  
                    id="volantiscategories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/tags/
                  
                  
                  
                    id="volantistags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/archives/
                  
                  
                  
                    id="volantisarchives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/friends/
                  
                  
                  
                    id="volantisfriends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
          
            
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/about/
                  
                  
                  
                    id="volantisabout"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
          
				</ul>
			</div>

      <div class="m_search">
        <form name="searchform" class="form u-search-form">
          <i class="icon fas fa-search fa-fw"></i>
          <input type="text" class="input u-search-input" placeholder="Search..." />
        </form>
      </div>

			<ul class='switcher nav-list-h m-phone'>
				
					<li><a class="s-search fas fa-search fa-fw" target="_self" href='javascript:void(0)'></a></li>
				
				<li>
          <a class="s-menu fas fa-bars fa-fw" target="_self" href='javascript:void(0)'></a>
          <ul class="menu-phone list-v navigation white-box">
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/
                  
                  
                  
                    id="volantis"
                  >
                  <i class='fas fa-rss fa-fw'></i>博客
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/categories/
                  
                  
                  
                    id="volantiscategories"
                  >
                  <i class='fas fa-folder-open fa-fw'></i>分类
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/tags/
                  
                  
                  
                    id="volantistags"
                  >
                  <i class='fas fa-tags fa-fw'></i>标签
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/archives/
                  
                  
                  
                    id="volantisarchives"
                  >
                  <i class='fas fa-archive fa-fw'></i>归档
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/friends/
                  
                  
                  
                    id="volantisfriends"
                  >
                  <i class='fas fa-link fa-fw'></i>友链
                </a>
                
              </li>
            
          
            
              
            
              <li>
                <a class="menuitem flat-box faa-parent animated-hover" href=/volantis/about/
                  
                  
                  
                    id="volantisabout"
                  >
                  <i class='fas fa-info-circle fa-fw'></i>关于
                </a>
                
              </li>
            
          
            
          </ul>
        </li>
			</ul>
		</div>
	</div>
  </div>
</header>

  <div class="l_body">
    <div class="l_cover">
  
    
    
        <div class='cover-wrapper post dock' style="display: none;">
          
            <div class='cover-bg lazyload placeholder' data-bg="https://cdn.jsdelivr.net/gh/volantis-x/cdn-wallpaper-minimalist/2020/033.jpg"></div>
          
          <div class='cover-body'>
  <div class='top'>
    
    
      <p class="title">Volantis</p>
    
    
  </div>
  <div class='bottom'>
    <div class='menu navigation'>
      <div class='list-h'>
        
          
            <a href="/volantis/v4/getting-started/"
              
              
              id="volantisv4getting-started">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f5c3.svg'><p>文档</p>
            </a>
          
            <a href="/volantis/faqs/"
              
              
              id="volantisfaqs">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f516.svg'><p>帮助</p>
            </a>
          
            <a href="/volantis/examples/"
              
              
              id="volantisexamples">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f396.svg'><p>示例</p>
            </a>
          
            <a href="/volantis/contributors/"
              
              
              id="volantiscontributors">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f389.svg'><p>社区</p>
            </a>
          
            <a href="/volantis/archives/"
              
              
              id="volantisarchives">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f4f0.svg'><p>博客</p>
            </a>
          
            <a target="_blank" rel="noopener" href="https://github.com/volantis-x/hexo-theme-volantis/"
              
              
              id="https:githubcomvolantis-xhexo-theme-volantis">
              <img src='https://cdn.jsdelivr.net/gh/twitter/twemoji@13.0/assets/svg/1f9ec.svg'><p>源码</p>
            </a>
          
        
      </div>
    </div>
  </div>
</div>

          <div class="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div>
        </div>
    
  
  </div>
  
    <div class='safearea'>
      <div class='body-wrapper' id="pjax-container">
        
          <!--此文件用来存放一些不方便取值的变量--> 
<!--思路大概是将值藏到重加载的区域内--> 
 
 
 
<div id="pjax-data" style="display: none"> 
  <div id="pjax-ispage">true</div> 
  <div id="pjax-pageTitle">生产实习</div> 
  <div id="pjax-enable-cover">true</div> 
  <div id="pjax-comment-path"></div> 
  <div id="pjax-comment-placeholder"></div> 
</div> 
 
 
<script> 
  // 处理封面 此时 jquery 还没加载 
  if ("half" == "none") { // 移除封面 
    document.getElementsByClassName('cover-wrapper')[0].style.display = "none"; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.add("show"); 
  } else { 
    if ("half" == "half") { // 半屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'half'); 
      document.getElementsByClassName('scroll-down')[0].style.display = "none"; 
    } else if ("half" == "full") { // 全屏 
      document.getElementsByClassName('cover-wrapper')[0].setAttribute('id', 'full'); 
      document.getElementsByClassName('scroll-down')[0].style.display = ""; 
    } 
    document.getElementsByClassName('cover-wrapper')[0].style.display = ""; 
    document.getElementsByClassName('l_header', 'cover-wrapper')[0].classList.remove("show"); 
  } 
</script> 
 

        
        

<div class='l_main'>
  <article class="article post white-box reveal md shadow article-type-post" id="post" itemscope itemprop="blogPost">
  


  
  <div class="article-meta" id="top">
    
    
    
      <h1 class="title">
        生产实习
      </h1>
      <div class='new-meta-box'>
        
          
            
<div class='new-meta-item author'>
  <a class='author' href="/" rel="nofollow">
    <img no-lazy src="">
    <p>请设置文章作者</p>
  </a>
</div>

          
        
          
            
  <div class='new-meta-item category'>
    <a class='notlink'>
      <i class="fas fa-folder-open fa-fw" aria-hidden="true"></i>
      <a class="category-link" href="/volantis/categories/%E5%AD%A6%E4%B9%A0/">学习</a><span class="sep"></span><a class="category-link" href="/volantis/categories/%E5%AD%A6%E4%B9%A0/%E7%94%9F%E4%BA%A7%E5%AE%9E%E4%B9%A0/">生产实习</a>
    </a>
  </div>


          
        
          
            <div class="new-meta-item date">
  <a class='notlink'>
    <i class="fas fa-calendar-alt fa-fw" aria-hidden="true"></i>
    <p>发布于：2020年6月29日</p>
  </a>
</div>

          
        
          
            
  <div class="new-meta-item browse leancloud">
    <a class='notlink'>
      
      <div id="lc-pv" data-title="生产实习" data-path="/volantis/posts/2/">
        <i class="fas fa-eye fa-fw" aria-hidden="true"></i>
        <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span>
        次浏览
      </div>
    </a>
  </div>


          
        
      </div>
    
  </div>


  
  <p><strong>等待更新中 时间为整点定时发布</strong></p>
<blockquote>
<p><strong>待同步</strong> <strong>取消加密</strong></p>
<p><strong>图片还未上传至图床</strong></p>
<p><strong>视频嵌入还未做好 YouTube已OK</strong> </p>
<p><strong>目录在左侧</strong></p>
</blockquote>
<h5 id="超声波及温度传感摇摆风扇"><a href="#超声波及温度传感摇摆风扇" class="headerlink" title="超声波及温度传感摇摆风扇"></a><strong>超声波及温度传感摇摆风扇</strong></h5><h6 id="所用元件："><a href="#所用元件：" class="headerlink" title="所用元件："></a><strong>所用元件：</strong></h6><p>UNO R3开发板 ×1</p>
<p>大面包板 ×1</p>
<p>舵机 ×1 </p>
<p>舵机支架 ×1</p>
<p>电位器 ×1</p>
<p>1k电阻 ×1</p>
<p>USB数据线 ×1</p>
<p>小风扇 ×1</p>
<p>摇头风扇支架组件 ×1</p>
<p>ULN2003AN驱动芯片 ×1</p>
<p>三色LED ×1</p>
<p>鳄鱼夹 ×2</p>
<p>面包线 若干</p>
<h6 id="开发环境：Arduino-IDE-Mind"><a href="#开发环境：Arduino-IDE-Mind" class="headerlink" title="开发环境：Arduino IDE,Mind+"></a><strong>开发环境：</strong>Arduino IDE,Mind+</h6><h6 id="预期要求："><a href="#预期要求：" class="headerlink" title="预期要求："></a><strong>预期要求：</strong></h6><p>通过超声波测距和温度传感控制舵机是否旋转，当距离小于30cm或温度大于30℃时在设定的角度之间来回旋转；通过电位器控制电机，小风扇旋转的快慢。</p>
<h6 id="大致设计思路："><a href="#大致设计思路：" class="headerlink" title="大致设计思路："></a><strong>大致设计思路：</strong></h6><h6 id="具体实现源代码："><a href="#具体实现源代码：" class="headerlink" title="具体实现源代码："></a><strong>具体实现源代码：</strong></h6><figure class="highlight c"><table><tr><td class="code"><pre><span class="line"><span class="comment">//引入库文件</span></span><br><span class="line">\<span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;Servo.h&gt;//舵机库，之间要有空格，否则编译时会报错。</span></span></span><br><span class="line">\<span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;Wire.h&gt; //是I2C通讯的，Arduino和I2C设备通讯使用的(SCLK DIN RCLK) </span></span></span><br><span class="line"><span class="comment">//以下为函数声明</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">zhuan</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">buzhuan</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">chaoshengbo</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">wendu</span><span class="params">()</span></span>;</span><br><span class="line"><span class="comment">//以下为变量声明及初始声明</span></span><br><span class="line">Servo myservo;<span class="comment">//定义舵机变量名</span></span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">char</span> jiao;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> P=A0;<span class="comment">//电位器输入引脚</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> U=<span class="number">8</span>;</span><br><span class="line"><span class="keyword">int</span> sensorValue=<span class="number">0</span>;<span class="comment">//电位器电压值</span></span><br><span class="line"><span class="keyword">int</span> outputValue=<span class="number">0</span>;</span><br><span class="line"><span class="comment">// 设定SR04连接的Arduino引脚</span></span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> TrigPin = <span class="number">10</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> EchoPin = <span class="number">11</span>;</span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">long</span> distance;</span><br><span class="line"><span class="keyword">int</span> temp;<span class="comment">//温度</span></span><br><span class="line"><span class="keyword">int</span> tol;<span class="comment">//校对码</span></span><br><span class="line"><span class="keyword">int</span> j;</span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">int</span> loopCnt;</span><br><span class="line"><span class="keyword">int</span> chr[<span class="number">40</span>] = &#123;<span class="number">0</span>&#125;;<span class="comment">//创建数字数组，用来存放40个bit</span></span><br><span class="line"><span class="keyword">unsigned</span> <span class="keyword">long</span> time;</span><br><span class="line">\<span class="meta">#<span class="meta-keyword">define</span> pin 2</span></span><br><span class="line"><span class="comment">//以下为主函数部分</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">setup</span><span class="params">()</span> <span class="comment">//初始设定</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> myservo.attach(<span class="number">9</span>);<span class="comment">//定义舵机接口</span></span><br><span class="line"> Serial.begin(<span class="number">9600</span>);<span class="comment">//设定波特率为9600 </span></span><br><span class="line"> pinMode(TrigPin, OUTPUT);<span class="comment">// 要检测引脚上输入的脉冲宽度，需要先设置为输入状态</span></span><br><span class="line"> pinMode(EchoPin, INPUT);</span><br><span class="line"> Serial.println(<span class="string">&quot;Ultrasonic sensor:&quot;</span>);</span><br><span class="line"> buzhuan();</span><br><span class="line"> chaoshengbo();</span><br><span class="line"> wendu();</span><br><span class="line"> &#125; </span><br><span class="line"><span class="comment">//以下为循环执行部分</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">loop</span><span class="params">()</span> </span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> chaoshengbo();</span><br><span class="line"> wendu();</span><br><span class="line"> delay(<span class="number">500</span>);</span><br><span class="line"> <span class="keyword">if</span> ((distance&lt;<span class="number">30</span>) || (temp&gt;<span class="number">30</span>)) </span><br><span class="line"> &#123;</span><br><span class="line">  digitalWrite(<span class="number">4</span>, LOW);<span class="comment">//红灯灭，代表舵机未旋转</span></span><br><span class="line">  digitalWrite(<span class="number">7</span>, HIGH);<span class="comment">//绿灯亮，代表舵机开始旋转</span></span><br><span class="line">  zhuan();</span><br><span class="line">  chaoshengbo();</span><br><span class="line">  wendu();</span><br><span class="line">  delay(<span class="number">500</span>);</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">else</span> <span class="keyword">if</span>((distance&gt;<span class="number">30</span>) || (temp&lt;<span class="number">30</span>))</span><br><span class="line">  &#123;</span><br><span class="line">  buzhuan();</span><br><span class="line">  chaoshengbo();</span><br><span class="line">  wendu();</span><br><span class="line">  delay(<span class="number">500</span>);</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">//以下为函数定义部分</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">zhuan</span><span class="params">()</span><span class="comment">//定义舵机转</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> myservo.write(jiao);</span><br><span class="line"> sensorValue=analogRead(P);</span><br><span class="line"> outputValue=<span class="built_in">map</span>(sensorValue,<span class="number">0</span>,<span class="number">1023</span>,<span class="number">0</span>,<span class="number">255</span>);</span><br><span class="line"> analogWrite(U,outputValue);</span><br><span class="line"> <span class="keyword">for</span>(jiao=<span class="number">30</span>;jiao&lt;<span class="number">150</span>;jiao++)</span><br><span class="line">  &#123;</span><br><span class="line">   myservo.write(jiao);<span class="comment">//设置舵机旋转的角度 </span></span><br><span class="line">   delay(<span class="number">10</span>);  </span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">for</span>(jiao=<span class="number">150</span>;jiao&gt;<span class="number">30</span>;jiao--)</span><br><span class="line">  &#123;</span><br><span class="line">   myservo.write(jiao);<span class="comment">//设置舵机旋转的角度 </span></span><br><span class="line">   delay(<span class="number">10</span>);  </span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">buzhuan</span><span class="params">()</span><span class="comment">//定义舵机不转</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> digitalWrite(TrigPin, LOW);</span><br><span class="line"> delayMicroseconds(<span class="number">2</span>);</span><br><span class="line"> myservo.write(jiao);</span><br><span class="line"> digitalWrite(<span class="number">4</span>, HIGH);</span><br><span class="line"> digitalWrite(<span class="number">7</span>, LOW);</span><br><span class="line"> sensorValue=analogRead(P);</span><br><span class="line"> outputValue=<span class="built_in">map</span>(sensorValue,<span class="number">0</span>,<span class="number">1023</span>,<span class="number">0</span>,<span class="number">255</span>);</span><br><span class="line"> analogWrite(U,outputValue);</span><br><span class="line"> myservo.write(jiao); </span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">chaoshengbo</span><span class="params">()</span><span class="comment">//定义超声波测距</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> <span class="comment">// 产生一个10us的高脉冲去触发TrigPin</span></span><br><span class="line"> digitalWrite(TrigPin, LOW);</span><br><span class="line"> delayMicroseconds(<span class="number">2</span>);</span><br><span class="line"> digitalWrite(TrigPin, HIGH);</span><br><span class="line"> delayMicroseconds(<span class="number">10</span>);</span><br><span class="line"> digitalWrite(TrigPin, LOW); <span class="comment">// 检测脉冲宽度，并计算出距离</span></span><br><span class="line"> <span class="comment">//delayMicroseconds(2);</span></span><br><span class="line"> distance = pulseIn(EchoPin, HIGH) / <span class="number">58.00</span>;</span><br><span class="line"> Serial.print(<span class="string">&quot;距离：&quot;</span>);</span><br><span class="line"> Serial.print(distance);</span><br><span class="line"> Serial.print(<span class="string">&quot;cm&quot;</span>);</span><br><span class="line"> Serial.println();</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">wendu</span><span class="params">()</span><span class="comment">//定义温度测量</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line"> bgn:</span><br><span class="line"> delay(<span class="number">500</span>);</span><br><span class="line"><span class="comment">//设置2号接口模式为：输出</span></span><br><span class="line"><span class="comment">//输出低电平20ms（&gt;18ms）</span></span><br><span class="line"><span class="comment">//输出高电平40μs</span></span><br><span class="line"> pinMode(pin,OUTPUT);</span><br><span class="line"> digitalWrite(pin,LOW);</span><br><span class="line"> delay(<span class="number">20</span>);</span><br><span class="line"> digitalWrite(pin,HIGH);</span><br><span class="line"> delayMicroseconds(<span class="number">40</span>);</span><br><span class="line"> digitalWrite(pin,LOW);</span><br><span class="line"><span class="comment">//设置2号接口模式：输入</span></span><br><span class="line"> pinMode(pin,INPUT);</span><br><span class="line"> <span class="comment">//高电平响应信号 </span></span><br><span class="line"> loopCnt=<span class="number">10000</span>;</span><br><span class="line"> <span class="keyword">while</span>(digitalRead(pin) != HIGH)</span><br><span class="line"> &#123;</span><br><span class="line">  <span class="keyword">if</span>(loopCnt-- == <span class="number">0</span>)</span><br><span class="line">  &#123;</span><br><span class="line"><span class="comment">//如果长时间不返回高电平，输出个提示，重头开始。</span></span><br><span class="line">   Serial.println(<span class="string">&quot;HIGH&quot;</span>);</span><br><span class="line">   <span class="keyword">goto</span> bgn;</span><br><span class="line">  &#125;</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="comment">//低电平响应信号</span></span><br><span class="line"> loopCnt=<span class="number">30000</span>;</span><br><span class="line"> <span class="keyword">while</span>(digitalRead(pin) != LOW)</span><br><span class="line"> &#123;</span><br><span class="line">  <span class="keyword">if</span>(loopCnt-- == <span class="number">0</span>)</span><br><span class="line">  &#123;</span><br><span class="line"><span class="comment">//如果长时间不返回低电平，输出个提示，重头开始。</span></span><br><span class="line">   Serial.println(<span class="string">&quot;LOW&quot;</span>);</span><br><span class="line">   <span class="keyword">goto</span> bgn;</span><br><span class="line">  &#125;</span><br><span class="line"> &#125;</span><br><span class="line"><span class="comment">//开始读取bit1-40的数值  </span></span><br><span class="line">  <span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;<span class="number">40</span>;i++)</span><br><span class="line"> &#123;</span><br><span class="line">  <span class="keyword">while</span>(digitalRead(pin) == LOW)</span><br><span class="line">  &#123;&#125;</span><br><span class="line"><span class="comment">//当出现高电平时，记下时间“time”</span></span><br><span class="line">  time = micros();</span><br><span class="line">  <span class="keyword">while</span>(digitalRead(pin) == HIGH)</span><br><span class="line">  &#123;&#125;</span><br><span class="line"><span class="comment">//当出现低电平，记下时间，再减去刚才储存的time</span></span><br><span class="line"><span class="comment">//得出的值若大于50μs，则为‘1’，否则为‘0’</span></span><br><span class="line"><span class="comment">//并储存到数组里去</span></span><br><span class="line">  <span class="keyword">if</span> (micros() - time &gt;<span class="number">50</span>)</span><br><span class="line">  &#123;</span><br><span class="line">   chr[i]=<span class="number">1</span>;</span><br><span class="line">  &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">   chr[i]=<span class="number">0</span>;</span><br><span class="line">  &#125;</span><br><span class="line"> &#125;  </span><br><span class="line"><span class="comment">//温度，8位的bit，转换为数值</span></span><br><span class="line">temp=chr[<span class="number">16</span>]*<span class="number">128</span>+chr[<span class="number">17</span>]*<span class="number">64</span>+chr[<span class="number">18</span>]*<span class="number">32</span>+chr[<span class="number">19</span>]*<span class="number">16</span>+chr[<span class="number">20</span>]*<span class="number">8</span>+chr[<span class="number">21</span>]*<span class="number">4</span>+chr[<span class="number">22</span>]*<span class="number">2</span>+chr[<span class="number">23</span>];</span><br><span class="line"> <span class="comment">//校对码，8位的bit，转换为数值</span></span><br><span class="line">tol=chr[<span class="number">32</span>]*<span class="number">128</span>+chr[<span class="number">33</span>]*<span class="number">64</span>+chr[<span class="number">34</span>]*<span class="number">32</span>+chr[<span class="number">35</span>]*<span class="number">16</span>+chr[<span class="number">36</span>]*<span class="number">8</span>+chr[<span class="number">37</span>]*<span class="number">4</span>+chr[<span class="number">38</span>]*<span class="number">2</span>+chr[<span class="number">39</span>];</span><br><span class="line"><span class="comment">//输出：温度、湿度、校对码</span></span><br><span class="line">  Serial.print(<span class="string">&quot;温度：&quot;</span>);</span><br><span class="line">  Serial.print(temp);</span><br><span class="line">  Serial.println(<span class="string">&quot;℃&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>串口串口显示情况1，此时温度为28℃，距离为275cm左右，都不满足舵机旋转的条件，红色指示灯常亮。</p>
<p>对应的实际运行情况如下图所示：</p>
<p>串口串口显示情况2，串口串口显示情况1，此时温度为28℃，距离为5cm左右，满足舵机旋转的条件，绿色指示灯常亮。</p>
<p>对应的实际运行情况如下图所示</p>
<h6 id="YouTube："><a href="#YouTube：" class="headerlink" title="YouTube："></a><strong>YouTube：</strong></h6><iframe width="900" height="506" src="https://www.youtube.com/embed/hSkkb7gR_kU" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
  
  
    
    <div class='footer'>
      
      
      
        <div class='copyright'>
          <blockquote>
            
              
                <p>博客内容遵循 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议</p>

              
            
              
                <p>本文永久链接是：<a href=https://ccknbc.github.io/volantis/posts/2/>https://ccknbc.github.io/volantis/posts/2/</a></p>
              
            
          </blockquote>
        </div>
      
      
    </div>
  
  
    


  <div class='article-meta' id="bottom">
    <div class='new-meta-box'>
      
        
          <div class="new-meta-item date" itemprop="dateUpdated" datetime="2020-06-29T13:00:00+00:00">
  <a class='notlink'>
    <i class="fas fa-edit fa-fw" aria-hidden="true"></i>
    <p>更新于：2020年6月29日</p>
  </a>
</div>

        
      
        
          
  
  <div class="new-meta-item meta-tags"><a class="tag" href="/volantis/tags/%E5%AD%A6%E4%B9%A0/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>学习</p></a></div> <div class="new-meta-item meta-tags"><a class="tag" href="/volantis/tags/%E7%94%9F%E4%BA%A7%E5%AE%9E%E4%B9%A0/" rel="nofollow"><i class="fas fa-hashtag fa-fw" aria-hidden="true"></i><p>生产实习</p></a></div>


        
      
        
          
  <div class="new-meta-item share -mob-share-list">
  <div class="-mob-share-list share-body">
    
      
        <a class="-mob-share-qq" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=https://ccknbc.github.io/volantis/posts/2/&title=生产实习 - CC康纳百川&summary="
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qq.png" srcset="">
          
        </a>
      
    
      
        <a class="-mob-share-qzone" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=https://ccknbc.github.io/volantis/posts/2/&title=生产实习 - CC康纳百川&summary="
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/qzone.png" srcset="">
          
        </a>
      
    
      
        <a class="-mob-share-weibo" title="" rel="external nofollow noopener noreferrer noopener"
          
          target="_blank" href="http://service.weibo.com/share/share.php?url=https://ccknbc.github.io/volantis/posts/2/&title=生产实习 - CC康纳百川&summary="
          
          >
          
            <img src="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png" class="lazyload" data-srcset="https://cdn.jsdelivr.net/gh/volantis-x/cdn-org/logo/128/weibo.png" srcset="">
          
        </a>
      
    
      
    
      
    
  </div>
</div>



        
      
    </div>
  </div>


  
  

  
    <div class="prev-next">
      
        <a class='prev' href='/volantis/posts/3/'>
          <p class='title'><i class="fas fa-chevron-left" aria-hidden="true"></i>HEXO折腾</p>
          <p class='content'>个人目前使用主题为Butterfly 3.0.1版本，HEXO 5.0.2版本
请按照以下步骤依次安装相应依赖和框架
搭建步骤安装 Node.js
什么是 Node.js ？这得从什么是 JS ...</p>
        </a>
      
      
        <a class='next' href='/volantis/posts/1/'>
          <p class='title'>基于小波变换的数字水印检测<i class="fas fa-chevron-right" aria-hidden="true"></i></p>
          <p class='content'>数字水印技术原理
数字水印技术实际上就是通过对水印载体的分析、水印信息的处理、水印嵌入点的选择、嵌入方式的设计、嵌入调制的控制和提取检测方法等相关技术环节进行合理优化，寻求满足不可感知性、鲁棒性...</p>
        </a>
      
    </div>
  
</article>


  

  






</div>
<aside class='l_side'>
  
  
    
    



  <section class="widget toc-wrapper shadow desktop mobile" id="toc-div" >
    
  <header>
    
      <i class="fas fa-list fa-fw" aria-hidden="true"></i><span class='name'>本文目录</span>
    
  </header>


    <div class='content'>
        <ol class="toc"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E8%B6%85%E5%A3%B0%E6%B3%A2%E5%8F%8A%E6%B8%A9%E5%BA%A6%E4%BC%A0%E6%84%9F%E6%91%87%E6%91%86%E9%A3%8E%E6%89%87"><span class="toc-text">超声波及温度传感摇摆风扇</span></a></li></ol>
    </div>
  </section>


  


</aside>



      </div>
      
  
  <footer class="footer clearfix">
    <br><br>
    
      
        <div class="aplayer-container">
          


        </div>
      
    
      
        <br>
        <div class="social-wrapper">
          
            
          
            
          
            
          
        </div>
      
    
      
        <div><p>博客内容遵循 <a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 协议</a></p>
</div>
      
    
      
        
          <div><p><span id="lc-sv">本站总访问量为 <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span> 次</span> <span id="lc-uv">访客数为 <span id='number'><i class="fas fa-circle-notch fa-spin fa-fw" aria-hidden="true"></i></span> 人</span></p>
</div>
        
      
    
      
        本站使用
        <a href="https://github.com/volantis-x/hexo-theme-volantis/tree/4.0.0-rc.4" target="_blank" class="codename">Volantis</a>
        作为主题
      
    
      
        <div class='copyright'>
        <p><a href="/">Copyright © 2017-2020 XXX</a></p>

        </div>
      
    
  </footer>


      <a class="s-top fas fa-arrow-up fa-fw" href='javascript:void(0)'></a>
    </div>
  </div>
  <div>
    <!-- required -->

<script src="https://cdn.jsdelivr.net/npm/jquery@3.5/dist/jquery.min.js"></script>

<script>
  function pjax_fancybox() {
    $(".md .gallery").find("img").each(function () { //渲染 fancybox
      var element = document.createElement("a"); // a 标签
      $(element).attr("class", "fancybox");
      $(element).attr("pjax-fancybox", "");  // 过滤 pjax
      $(element).attr("href", $(this).attr("src"));
      if ($(this).attr("data-original")) {
        $(element).attr("href", $(this).attr("data-original"));
      }
      $(element).attr("data-fancybox", "images");
      var caption = "";   // 描述信息
      if ($(this).attr('alt')) {  // 判断当前页面是否存在描述信息
        $(element).attr('data-caption', $(this).attr('alt'));
        caption = $(this).attr('alt');
      }
      var div = document.createElement("div");
      $(div).addClass("fancybox");
      $(this).wrap(div); // 最外层套 div ，其实主要作用还是 class 样式
      var span = document.createElement("span");
      $(span).addClass("image-caption");
      $(span).text(caption); // 加描述
      $(this).after(span);  // 再套一层描述
      $(this).wrap(element);  // 最后套 a 标签
    })
    $(".md .gallery").find("img").fancybox({
      selector: '[data-fancybox="images"]',
      hash: false,
      loop: false,
      closeClick: true,
      helpers: {
        overlay: {closeClick: true}
      },
      buttons: [
        "zoom",
        "close"
      ]
    });
  };
  function SCload_fancybox() {
    if ($(".md .gallery").find("img").length == 0) return;
    loadCSS("https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css", document.getElementById("loadcss"));
    setTimeout(function() {
      loadScript('https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js', pjax_fancybox)
    }, 1);
  };
  $(function () {
    SCload_fancybox();
  });
</script>


<!-- internal -->







  <script defer src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.1.0/dist/lazyload.min.js"></script>
<script>
  // https://www.npmjs.com/package/vanilla-lazyload
  // Set the options globally
  // to make LazyLoad self-initialize
  window.lazyLoadOptions = {
    elements_selector: ".lazyload",
    threshold: 0
  };
  // Listen to the initialization event
  // and get the instance of LazyLoad
  window.addEventListener(
    "LazyLoad::Initialized",
    function (event) {
      window.lazyLoadInstance = event.detail.instance;
    },
    false
  );
  document.addEventListener('DOMContentLoaded', function () {
    lazyLoadInstance.update();
  });
  document.addEventListener('pjax:complete', function () {
    lazyLoadInstance.update();
  });
</script>




  
  
    <script>
      window.FPConfig = {
        delay: 0,
        ignoreKeywords: [],
        maxRPS: 5,
        hoverDelay: 25
      };
    </script>
    <script defer src="https://cdn.jsdelivr.net/gh/gijo-varghese/flying-pages@2.1.2/flying-pages.min.js"></script>
  















  
<script src="/volantis/js/app.js"></script>




  
    
<script src="/volantis/js/search.js"></script>

  


<!-- optional -->

  <script>
const SearchServiceimagePath="https://cdn.jsdelivr.net/gh/volantis-x/cdn-volantis@master/img/";
const ROOT =  ("/volantis/" || "/").endsWith('/') ? ("/volantis/" || "/") : ("/volantis//" || "/" );
(function ($) {
  
    customSearch = new HexoSearch({
      imagePath: SearchServiceimagePath
    });
  
})(jQuery);

</script>











  <script defer>

  const LCCounter = {
    app_id: 'yPKOAo6M4zHWCq3jzS0iqLEW-MdYXbMMI',
    app_key: 'Vt6syMPvpjnscIVTQNFAX0jj',
    custom_api_server: '',

    // 查询存储的记录
    getRecord(Counter, url, title) {
      return new Promise(function (resolve, reject) {
        Counter('get', '/classes/Counter?where=' + encodeURIComponent(JSON.stringify({url})))
          .then(resp => resp.json())
          .then(({results, code, error}) => {
            if (code === 401) {
              throw error;
            }
            if (results && results.length > 0) {
              var record = results[0];
              resolve(record);
            } else {
              Counter('post', '/classes/Counter', {url, title: title, times: 0})
                .then(resp => resp.json())
                .then((record, error) => {
                  if (error) {
                    throw error;
                  }
                  resolve(record);
                }).catch(error => {
                console.error('Failed to create', error);
                reject(error);
              });
            }
          }).catch((error) => {
          console.error('LeanCloud Counter Error:', error);
          reject(error);
        });
      })
    },

    // 发起自增请求
    increment(Counter, incrArr) {
      return new Promise(function (resolve, reject) {
        Counter('post', '/batch', {
          "requests": incrArr
        }).then((res) => {
          res = res.json();
          if (res.error) {
            throw res.error;
          }
          resolve(res);
        }).catch((error) => {
          console.error('Failed to save visitor count', error);
          reject(error);
        });
      });
    },

    // 构建自增请求体
    buildIncrement(objectId) {
      return {
        "method": "PUT",
        "path": `/1.1/classes/Counter/${ objectId }`,
        "body": {
          "times": {
            '__op': 'Increment',
            'amount': 1
          }
        }
      }
    },

    // 校验是否为有效的 UV
    validUV() {
      var key = 'LeanCloudUVTimestamp';
      var flag = localStorage.getItem(key);
      if (flag) {
        // 距离标记小于 24 小时则不计为 UV
        if (new Date().getTime() - parseInt(flag) <= 86400000) {
          return false;
        }
      }
      localStorage.setItem(key, new Date().getTime().toString());
      return true;
    },

    addCount(Counter) {
      var enableIncr = '' === 'true' && window.location.hostname !== 'localhost';
      enableIncr = true;
      var getterArr = [];
      var incrArr = [];
      // 请求 PV 并自增
      var pvCtn = document.querySelector('#lc-sv');
      if (pvCtn || enableIncr) {
        var pvGetter = this.getRecord(Counter, 'https://ccknbc.github.io/volantis' + '/#lc-sv', 'Visits').then((record) => {
          incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-sv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + 1;
              if (pvCtn) {
                pvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(pvGetter);
      }

      // 请求 UV 并自增
      var uvCtn = document.querySelector('#lc-uv');
      if (uvCtn || enableIncr) {
        var uvGetter = this.getRecord(Counter, 'https://ccknbc.github.io/volantis' + '/#lc-uv', 'Visitors').then((record) => {
          var vuv = this.validUV();
          vuv && incrArr.push(this.buildIncrement(record.objectId))
          var eles = document.querySelectorAll('#lc-uv #number');
          if (eles.length > 0) {
            eles.forEach((el,index,array)=>{
              el.innerText = record.times + (vuv ? 1 : 0);
              if (uvCtn) {
                uvCtn.style.display = 'inline';
              }
            })
          }
        });
        getterArr.push(uvGetter);
      }

      // 请求文章的浏览数，如果是当前页面就自增
      var allPV = document.querySelectorAll('#lc-pv');
      if (allPV.length > 0 || enableIncr) {
        for (i = 0; i < allPV.length; i++) {
          let pv = allPV[i];
          let title = pv.getAttribute('data-title');
          var url = 'https://ccknbc.github.io/volantis' + pv.getAttribute('data-path');
          if (url) {
            var viewGetter = this.getRecord(Counter, url, title).then((record) => {
              // 是当前页面就自增
              let curPath = window.location.pathname;
              if (curPath.includes('index.html')) {
                curPath = curPath.substring(0, curPath.lastIndexOf('index.html'));
              }
              if (pv.getAttribute('data-path') == curPath) {
                incrArr.push(this.buildIncrement(record.objectId));
              }
              if (pv) {
                var ele = pv.querySelector('#lc-pv #number');
                if (ele) {
                  if (pv.getAttribute('data-path') == curPath) {
                    ele.innerText = (record.times || 0) + 1;
                  } else {
                    ele.innerText = record.times || 0;
                  }
                  pv.style.display = 'inline';
                }
              }
            });
            getterArr.push(viewGetter);
          }
        }
      }

      // 如果启动计数自增，批量发起自增请求
      if (enableIncr) {
        Promise.all(getterArr).then(() => {
          incrArr.length > 0 && this.increment(Counter, incrArr);
        })
      }

    },


    fetchData(api_server) {
      var Counter = (method, url, data) => {
        return fetch(`${ api_server }/1.1${ url }`, {
          method,
          headers: {
            'X-LC-Id': this.app_id,
            'X-LC-Key': this.app_key,
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      this.addCount(Counter);
    },

    refreshCounter() {
      var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`;
      if (api_server) {
        this.fetchData(api_server);
      } else {
        fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id)
          .then(resp => resp.json())
          .then(({api_server}) => {
            this.fetchData('https://' + api_server);
          });
      }
    }

  };

  LCCounter.refreshCounter();

  document.addEventListener('pjax:complete', function () {
    LCCounter.refreshCounter();
  });
</script>



<!-- more -->


    
      


<script src="https://cdn.jsdelivr.net/npm/pjax@0.2.8/pjax.min.js"></script>

<!-- 样式位于：source/css/_third-party/pjaxanimate.styl -->

<div class="pjax-animate">
  
    <script src="https://cdn.jsdelivr.net/npm/nprogress@0.2.0/nprogress.min.js"></script>
    <div id="loading-bar-wrapper"><script>NProgress.configure({parent:"#loading-bar-wrapper",trickleSpeed: 100})</script></div>
    <script>
      window.ShowLoading = function() {
        NProgress.start();
      };
      window.HideLoading = function() {
        NProgress.done();
      }
    </script>
  
</div>

<script>
    var pjax;
    document.addEventListener('DOMContentLoaded', function () {
      pjax = new Pjax({
        elements: 'a[href]:not([href^="#"]):not([href="javascript:void(0)"]):not([pjax-fancybox])',
        selectors: [
          "title",
          "#pjax-container",
          "#pjax-header-nav-list"
        ],
        cacheBust: false,   // url 地址追加时间戳，用以避免浏览器缓存
        timeout: 5000
      });
    });

    document.addEventListener('pjax:send', function (e) {
      window.stop(); // 相当于点击了浏览器的停止按钮

      try {
        var currentUrl = window.location.pathname;
        var targetUrl = e.triggerElement.href;
        var banUrl = [""];
        if (banUrl[0] != "") {
          banUrl.forEach(item => {
            if(currentUrl.indexOf(item) != -1 || targetUrl.indexOf(item) != -1) {
              window.location.href = targetUrl;
            }
          });
        }
      } catch (error) {}

      window.subData = null; // 移除标题（用于一二级导航栏切换处）
      if (typeof $.fancybox != "undefined") {
        $.fancybox.close();    // 关闭弹窗
      }
      $('.l_header .switcher .s-search').removeClass('active'); // 关闭移动端激活的搜索框
      $('.l_header').removeClass('z_search-open'); // 关闭移动端激活的搜索框
      $('.wrapper').removeClass('sub'); // 跳转页面时关闭二级导航

      // 解绑事件 避免重复监听
      $('.s-top').unbind('click');
      $('.menu a').unbind('click');
      $(window).unbind('resize');
      $(window).unbind('scroll');
      $(document).unbind('scroll');
      $(document).unbind('click');
      $('body').unbind('click');
      window.ShowLoading();
    });

    document.addEventListener('pjax:complete', function () {
      // 关于百度统计对 SPA 页面的处理：
      // 方案一：百度统计>管理>单页应用设置中，打开开启按钮即可对SPA进行统计。 https://tongji.baidu.com/web/help/article?id=324
      // 方案二：取消注释下列代码。 https://tongji.baidu.com/web/help/article?id=235
      // 

      // 关于谷歌统计对 SPA 页面的处理：
      // 当应用以动态方式加载内容并更新地址栏中的网址时，也应该更新通过 gtag.js 存储的网页网址。
      // https://developers.google.cn/analytics/devguides/collection/gtagjs/single-page-applications?hl=zh-cn
      

      $('.nav-main').find('.list-v').not('.menu-phone').removeAttr("style",""); // 移除小尾巴的移除
      $('.menu-phone.list-v').removeAttr("style",""); // 移除小尾巴的移除
      $('script[data-pjax], .pjax-reload script').each(function () {
        $(this).parent().append($(this).remove());
      });
      try{
          if (typeof $.fancybox == "undefined") {
            SCload_fancybox();
          } else {
            pjax_fancybox();
          }
        
        
        
        
        
        
        
        
        
        
      } catch (e) {
        console.log(e);
      }
      window.HideLoading();
    });

    document.addEventListener('pjax:error', function (e) {
      window.HideLoading();
      window.location.href = e.triggerElement.href;
    });
</script>

    
  </div>
</body>
</html>
